
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Modelsim 仿真 · WQ GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-callouts/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/styles.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="sec_4.html" />
    
    
    <link rel="prev" href="sec_2.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../lab0/introduction.html">
            
                <a href="../lab0/introduction.html">
            
                    
                    LAB0: 工欲善其事 必先利其器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../lab0/FPGAintro.html">
            
                <a href="../lab0/FPGAintro.html">
            
                    
                    FPGA 简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../lab0/whyFPGA.html">
            
                <a href="../lab0/whyFPGA.html">
            
                    
                    为什么是 FPGA？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../lab0/design_method.html">
            
                <a href="../lab0/design_method.html">
            
                    
                    设计方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../lab0/board_intro.html">
            
                <a href="../lab0/board_intro.html">
            
                    
                    平台介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../lab0/intro_tools.html">
            
                <a href="../lab0/intro_tools.html">
            
                    
                    软硬件关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../lab0/keil.html">
            
                <a href="../lab0/keil.html">
            
                    
                    Keil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../lab0/vivado.html">
            
                <a href="../lab0/vivado.html">
            
                    
                    Vivado
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../lab0/modelsim.html">
            
                <a href="../lab0/modelsim.html">
            
                    
                    Modelsim
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../lab1/introduction.html">
            
                <a href="../lab1/introduction.html">
            
                    
                    LAB1: "施法"让 CPU 动起来
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../lab1/sec_1.html">
            
                <a href="../lab1/sec_1.html">
            
                    
                    ARM 汇编回顾
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../lab1/sec_2.html">
            
                <a href="../lab1/sec_2.html">
            
                    
                    搭建 Keil 环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../lab1/sec_3.html">
            
                <a href="../lab1/sec_3.html">
            
                    
                    运行吧, 第一个汇编程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../lab1/sec_5.html">
            
                <a href="../lab1/sec_5.html">
            
                    
                    栈 - 函数调用的指挥官
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../lab1/sec_6.html">
            
                <a href="../lab1/sec_6.html">
            
                    
                    自己动手, 理解函数调用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="introduction.html">
            
                <a href="introduction.html">
            
                    
                    LAB2: "点石成金" - 实现你的首个 SoC
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="sec_1.html">
            
                <a href="sec_1.html">
            
                    
                    硬件部分说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="sec_2.html">
            
                <a href="sec_2.html">
            
                    
                    搭建 Keil 工程
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.3" data-path="sec_3.html">
            
                <a href="sec_3.html">
            
                    
                    Modelsim 仿真
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="sec_4.html">
            
                <a href="sec_4.html">
            
                    
                    下载比特流到 FPGA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="sec_5.html">
            
                <a href="sec_5.html">
            
                    
                    将硬件固化到开发板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="sec_6.html">
            
                <a href="sec_6.html">
            
                    
                    使用 Keil 调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../lab3/introduction.html">
            
                <a href="../lab3/introduction.html">
            
                    
                    LAB3: "灯, 等灯, 等灯"-流水灯的几种点法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../lab3/data_storage.html">
            
                <a href="../lab3/data_storage.html">
            
                    
                    数据存储器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../lab3/GPIO.html">
            
                <a href="../lab3/GPIO.html">
            
                    
                    GPIO外设实现流水灯
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../lab3/WaterLight.html">
            
                <a href="../lab3/WaterLight.html">
            
                    
                    硬件流水灯
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../lab4/introduction.html">
            
                <a href="../lab4/introduction.html">
            
                    
                    LAB4: 如何召唤"沉睡的软件"
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../lab4/keyboards.html">
            
                <a href="../lab4/keyboards.html">
            
                    
                    矩阵键盘原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../lab4/keyboards_waterlight.html">
            
                <a href="../lab4/keyboards_waterlight.html">
            
                    
                    使用矩阵键盘4个按键控制流水灯模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../lab4/keyboards_led.html">
            
                <a href="../lab4/keyboards_led.html">
            
                    
                    使用矩阵键盘控制数码管显示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../verilog/introduction.html">
            
                <a href="../verilog/introduction.html">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../verilog/grammar.html">
            
                <a href="../verilog/grammar.html">
            
                    
                    Verilog基本语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../verilog/enable_signal.html">
            
                <a href="../verilog/enable_signal.html">
            
                    
                    使能信号
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../verilog/decoder.html">
            
                <a href="../verilog/decoder.html">
            
                    
                    总线译码器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../faq/introduction.html">
            
                <a href="../faq/introduction.html">
            
                    
                    常见问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../add_notice.html">
            
                <a href="../add_notice.html">
            
                    
                    补充通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../about/introduction.html">
            
                <a href="../about/introduction.html">
            
                    
                    About
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Modelsim 仿真</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="modelsim-&#x4EFF;&#x771F;">Modelsim &#x4EFF;&#x771F;</h1>
<p>&#x6253;&#x5F00; Modelsim &#x8F6F;&#x4EF6;, &#x70B9;&#x51FB;&#x5DE6;&#x4E0A;&#x89D2; File &#x83DC;&#x5355;, &#x518D;&#x70B9;&#x51FB; New -&gt; Project &#x521B;&#x5EFA;&#x4E00;&#x4E2A; Modelsim &#x5DE5;&#x7A0B;, &#x547D;&#x540D;&#x4E3A; &quot;code&quot;, &#x5DE5;&#x7A0B;&#x5730;&#x5740;&#x9009;&#x4E3A; &quot;/Task2/modelsim/&quot; &#x6587;&#x4EF6;&#x5939;.</p>
<center><img src="../img/lab2/05.png" alt="05" style="zoom:75%;"></center><center style="color:#0" ;="">&#x65B0;&#x5EFA; Modelsim &#x5DE5;&#x7A0B;</center> 

<p>&#x70B9;&#x51FB; OK &#x540E;, &#x9009;&#x62E9; Add Existing File, &#x6DFB;&#x52A0;&#x6E90;&#x6587;&#x4EF6;.</p>
<center><img src="../img/lab2/16.png" alt="16" style="zoom:75%;"></center><center style="color:#0" ;="">&#x6DFB;&#x52A0;&#x6E90;&#x6587;&#x4EF6;</center> 

<p>&#x7531;&#x4E8E;&#x6211;&#x4EEC;&#x7684;&#x8F6F;&#x4EF6;&#x7A0B;&#x5E8F;&#x5DF2;&#x7ECF;&#x88AB; &quot;&#x4E0B;&#x8F7D;&quot; &#x5230;&#x4E86; RAM &#x4E2D;, &#x8FD9;&#x91CC;&#x53EA;&#x9700;&#x8981;&#x628A; &quot;/Task2/rtl/&quot; &#x4E0B;&#x7684;&#x6240;&#x6709;&#x7684; RTL &#x6587;&#x4EF6;&#x6DFB;&#x52A0;&#x8FDB;&#x6765;, &#x53E6;&#x5916;, &#x8FD8;&#x9700;&#x8981;&#x628A; Testbench &#x6587;&#x4EF6; &quot;/Task2/modelsim/CortexM0_SoC_vlg_tst.v&quot; &#x4E2D;&#x7684;&#x6DFB;&#x52A0;&#x8FDB;&#x6765;.</p>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="&#x4EC0;&#x4E48;&#x662F;-testbench-"><i class="fa fa-bullhorn"></i> &#x4EC0;&#x4E48;&#x662F; Testbench ?</h5></div><div class="panel-body"><p>Testbench &#x662F;&#x6570;&#x5B57;&#x7CFB;&#x7EDF;&#x4EFF;&#x771F;&#x7684;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;, &#x4EE5; verilog module &#x7684;&#x5F62;&#x5F0F;&#x5B58;&#x5728;, Testbench &#x7528;&#x4E8E;&#x6D4B;&#x8BD5;&#x6FC0;&#x52B1;&#x7684;&#x4EA7;&#x751F;&#x548C;&#x54CD;&#x5E94;&#x4FE1;&#x53F7;&#x7684;&#x6536;&#x96C6;&#x5904;&#x7406;, &#x867D;&#x7136;&#x4E0D;&#x5C5E;&#x4E8E;&#x8BBE;&#x8BA1;&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;, &#x4F46;&#x5FC5;&#x987B;&#x662F;&#x4EFF;&#x771F;&#x65F6;&#x7684;&#x9876;&#x5C42;&#x6587;&#x4EF6;.</p></div></div>
<!-- -->
<div class="panel panel-info"><div class="panel-heading"><h5 class="panel-title" id="&#x5173;&#x4E8E;&#x672C;&#x5B9E;&#x9A8C;&#x4E2D;&#x7684;-testbench"><i class="fa fa-comment"></i> &#x5173;&#x4E8E;&#x672C;&#x5B9E;&#x9A8C;&#x4E2D;&#x7684; Testbench</h5></div><div class="panel-body"><p>&#x6253;&#x5F00; &quot;/Task2/modelsim/CortexM0_SoC_vlg_tst.v&quot; &#x53EF;&#x4EE5;&#x770B;&#x5230;:</p><pre><code class="lang-verilog">`<span class="hljs-keyword">timescale</span> <span class="hljs-number">1</span> ps/ <span class="hljs-number">1</span> ps
<span class="hljs-keyword">module</span> CortexM0_SoC_vlg_tst();

<span class="hljs-keyword">reg</span> clk;
<span class="hljs-keyword">reg</span> RSTn;
<span class="hljs-keyword">reg</span> TXD;

CortexM0_SoC i1 (
    .clk(clk),
    .RSTn(RSTn)
);

<span class="hljs-keyword">initial</span> <span class="hljs-keyword">begin</span>                                                  
    clk = <span class="hljs-number">0</span>; RSTn=<span class="hljs-number">0</span>;
    #<span class="hljs-number">100</span> RSTn=<span class="hljs-number">1</span>;
<span class="hljs-keyword">end</span>  

<span class="hljs-keyword">always</span> <span class="hljs-keyword">begin</span> #<span class="hljs-number">10</span> clk = ~clk; <span class="hljs-keyword">end</span>       

<span class="hljs-keyword">endmodule</span>
</code></pre><p>&#x53EF;&#x89C1;, Testbench &#x4E2D;&#x53EA;&#x662F;&#x5BF9;&#x6574;&#x4E2A; SoC &#x505A;&#x4E86;&#x7B80;&#x5355;&#x7684;&#x4F8B;&#x5316;, &#x5E76;&#x63D0;&#x4F9B;&#x4E86;&#x65F6;&#x949F;&#x4FE1;&#x53F7;&#x548C;&#x521D;&#x59CB;&#x590D;&#x4F4D;.</p></div></div>
<p>&#x6587;&#x4EF6;&#x6DFB;&#x52A0;&#x5B8C;&#x6BD5;&#x540E;, &#x70B9;&#x51FB;&#x7F16;&#x8BD1;&#x6309;&#x94AE;, &#x5BF9;&#x6240;&#x6709;&#x6E90;&#x6587;&#x4EF6;&#x8FDB;&#x884C;&#x7F16;&#x8BD1;&#x67E5;&#x9519;. &#x901A;&#x8FC7;&#x7F16;&#x8BD1;&#x7684;&#x6587;&#x4EF6;&#x540E;&#x7684; &quot;?&quot; &#x90FD;&#x53D8;&#x6210;&#x4E86; &quot;&#x221A;&quot;:</p>
<center><img src="../img/lab2/07.png" alt="07" style="zoom:65%;"></center><center style="color:#0" ;="">&#x7F16;&#x8BD1;&#x4E4B;&#x524D;</center> 

<center><img src="../img/lab2/08.png" alt="08" style="zoom:69%;"></center><center style="color:#0" ;="">&#x7F16;&#x8BD1;&#x901A;&#x8FC7;</center> 

<p>&#x6B63;&#x5982;&#x4E4B;&#x524D;&#x6240;&#x8BF4;, Testbench &#x662F;&#x4EFF;&#x771F;&#x65F6;&#x7684;&#x9876;&#x5C42;&#x6587;&#x4EF6;, &#x6240;&#x4EE5;&#x4EFF;&#x771F;&#x7684;&#x5BF9;&#x8C61;&#x5E94;&#x8BE5;&#x662F; Testbench &#x6587;&#x4EF6;. &#x6211;&#x4EEC;&#x9009;&#x62E9;&#x5DE6;&#x4FA7;&#x5BFC;&#x822A;&#x680F;&#x4E0B;&#x65B9;&#x7684; Library, &#x5C55;&#x5F00; work, &#x53F3;&#x952E;&#x5355;&#x51FB; CortexM0_SoC_vlg_tst, &#x9009;&#x62E9; Simulate without Optimization, &#x5F00;&#x59CB;&#x4EFF;&#x771F;.</p>
<center><img src="../img/lab2/06.png" alt="06" style="zoom:75%;"></center><center style="color:#0" ;="">&#x9009;&#x62E9; Library -&gt; work -&gt; CortexM0_SoC_vlg_tst</center> 

<center><img src="../img/lab2/09.png" alt="09" style="zoom:75%;"></center><center style="color:#0" ;="">&#x53F3;&#x952E; CortexM0_SoC_vlg_tst &#x9009;&#x62E9; Simulate without Optimization</center> 

<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="instance-object-&#x548C;-wave"><i class="fa fa-bullhorn"></i> Instance, Object &#x548C; Wave</h5></div><div class="panel-body"><p>&#x4EFF;&#x771F;&#x65F6;&#x4E09;&#x4E2A;&#x975E;&#x5E38;&#x91CD;&#x8981;&#x7684;&#x7A97;&#x53E3;:</p><ul>
<li>Instance: &#x4EE5; Testbench &#x4E3A;&#x9876;&#x5C42;&#x6A21;&#x5757;, &#x5C42;&#x6B21;&#x5316;&#x5730;&#x5C55;&#x793A;&#x6240;&#x6709;&#x88AB;&#x4F8B;&#x5316;&#x7684;&#x6A21;&#x5757;. &#x6CE8;&#x610F;, &#x5C55;&#x793A;&#x7684;&#x662F;&#x5B9E;&#x4F8B;&#x540D;&#x800C;&#x4E0D;&#x662F;&#x6A21;&#x5757;&#x540D;.</li>
<li>Object: &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x5C55;&#x793A;&#x4E86;&#x67D0;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x4FE1;&#x53F7;.</li>
<li>Wave: &#x6CE2;&#x5F62;&#x7A97;&#x53E3;, &#x5C55;&#x793A;&#x88AB;&#x6DFB;&#x52A0;&#x7684;&#x4FE1;&#x53F7;&#x53CA;&#x5176;&#x6CE2;&#x5F62;.</li>
</ul><p>&#x5728; Modelsim &#x4E2D;, &#x5982;&#x679C;&#x4E0D;&#x5C0F;&#x5FC3;&#x5173;&#x95ED;&#x4E86;&#x8FD9;&#x4E9B;&#x7A97;&#x53E3;, &#x53EF;&#x4EE5;&#x5728; View &#x83DC;&#x5355;&#x680F;&#x4E2D;&#x91CD;&#x65B0;&#x6253;&#x5F00;.</p></div></div>
<p>&#x4E0B;&#x4E00;&#x6B65;, &#x6211;&#x4EEC;&#x8981;&#x628A;&#x5F85;&#x89C2;&#x5BDF;&#x7684;&#x4FE1;&#x53F7;&#x6DFB;&#x52A0;&#x5230; Wave &#x7A97;&#x53E3;. &#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x6DFB;&#x52A0;&#x54EA;&#x4E9B;&#x4FE1;&#x53F7;&#x5462;? &#x4E3A;&#x4E86;&#x89C2;&#x5BDF;&#x7A0B;&#x5E8F;&#x7684;&#x8FD0;&#x884C;&#x60C5;&#x51B5;, &#x6211;&#x4EEC;&#x9700;&#x8981;&#x89C2;&#x5BDF;&#x5904;&#x7406;&#x5668;&#x4E2D;&#x5BC4;&#x5B58;&#x5668;&#x7684;&#x503C;, &#x800C; Cortex-M0 &#x4E2D;&#x7684;&#x8C03;&#x8BD5;&#x63A5;&#x53E3;&#x6070;&#x597D;&#x6709;&#x6355;&#x6349;&#x5BC4;&#x5B58;&#x5668;&#x503C;&#x7684;&#x529F;&#x80FD;, &#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x628A; Cortex-M0 &#x4E2D;&#x7684;&#x5BF9;&#x5E94;&#x4FE1;&#x53F7;&#x6DFB;&#x52A0;&#x8FDB;&#x6765;&#x5373;&#x53EF;.</p>
<p>&#x6CE8;&#x610F;, &#x5728; CortexM0_SoC_vlg_tst.v &#x4E2D;, SoC &#x7684;&#x5B9E;&#x4F8B;&#x540D;&#x4E3A; i1, &#x800C;&#x5728; SoC &#x4E2D;, Cortex-M0 &#x6838;&#x7684;&#x5B9E;&#x4F8B;&#x540D;&#x4E3A; u_logic. &#x6211;&#x4EEC;&#x5728; Instance &#x7A97;&#x53E3;&#x4E2D;&#x5C55;&#x5F00; CortexM0_SoC_vlg_tst, &#x4F9D;&#x6B21;&#x9009;&#x62E9; i1 -&gt; u_logic. </p>
<p>&#x53CC;&#x51FB; u_logic, &#x8BE5;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x4FE1;&#x53F7;&#x5C31;&#x5448;&#x73B0;&#x5728;&#x4E86; Object &#x7A97;&#x53E3;&#x4E2D;. &#x5728; Object &#x7A97;&#x53E3;&#x4E2D;&#x9009;&#x4E2D;&#x8C03;&#x8BD5;&#x4FE1;&#x53F7; vis_r0_o, vis_r1_o, vis_pc_o; &#x53E6;&#x5916;, &#x4E3A;&#x4E86;&#x89C2;&#x5BDF; Cortex-M0 &#x6570;&#x636E;&#x63A5;&#x53E3;&#x7684;&#x5DE5;&#x4F5C;&#x8FC7;&#x7A0B;, &#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x9009;&#x4E2D; HADDR, HSIZE, HTRANS, HRDATA &#x8FD9;&#x51E0;&#x4E2A; AHB &#x4FE1;&#x53F7;, &#x53F3;&#x952E;&#x70B9;&#x51FB; Add Wave, &#x8FD9;&#x4E9B;&#x4FE1;&#x53F7;&#x5C31;&#x88AB;&#x6DFB;&#x52A0;&#x5230;&#x4E86; Wave &#x7A97;&#x53E3;&#x4E2D;.</p>
<center><img src="../img/lab2/11.png" alt="11" style="zoom:80%;"></center><center style="color:#0" ;="">&#x9009;&#x62E9;&#x5F85;&#x89C2;&#x5BDF;&#x7684;&#x4FE1;&#x53F7;</center> 

<p>&#x5728; Wave &#x7A97;&#x53E3;&#x4E2D;&#x9009;&#x4E2D;&#x6240;&#x6709;&#x4FE1;&#x53F7;, &#x53F3;&#x952E;&#x70B9;&#x51FB; Radix -&gt; Hexadecimal, &#x5C06;&#x5176;&#x6539;&#x4E3A; 16 &#x8FDB;&#x5236;&#x663E;&#x793A;, &#x4EE5;&#x4FBF;&#x89C2;&#x5BDF;.</p>
<center><img src="../img/lab2/12.png" alt="12" style="zoom:100%;"></center><center style="color:#0" ;="">Wave &#x7A97;&#x53E3;&#x4E2D;&#x7684;&#x4FE1;&#x53F7;</center> 

<!-- -->
<div class="panel panel-success"><div class="panel-heading"><h5 class="panel-title" id="&#x4FDD;&#x5B58;&#x6CE2;&#x5F62;&#x683C;&#x5F0F;"><i class="fa fa-lightbulb-o"></i> &#x4FDD;&#x5B58;&#x6CE2;&#x5F62;&#x683C;&#x5F0F;</h5></div><div class="panel-body"><p>&#x5728; Modelsim &#x4E2D;, &#x6240;&#x6709;&#x5BF9;&#x6CE2;&#x5F62;&#x683C;&#x5F0F; (&#x5982;&#x663E;&#x793A;&#x683C;&#x5F0F;, &#x989C;&#x8272;, &#x4FE1;&#x53F7;&#x5206;&#x7EC4;) &#x7684;&#x4FEE;&#x6539;&#x53EF;&#x4EE5;&#x88AB;&#x4FDD;&#x5B58;&#x4E3A;&#x4E00;&#x4E2A; do &#x811A;&#x672C;&#x6587;&#x4EF6;, &#x4EE5;&#x4FBF;&#x4E0B;&#x6B21;&#x8FDB;&#x5165;&#x4EFF;&#x771F;&#x540E;&#x52A0;&#x8F7D;&#x6267;&#x884C;. </p><p>&#x4FDD;&#x5B58;&#x65B9;&#x5F0F;&#x4E3A;: &#x70B9;&#x51FB; Wave &#x7A97;&#x53E3;&#x5DE6;&#x4E0A;&#x89D2; File &#x83DC;&#x5355;, &#x9009;&#x62E9; Save Format:</p><p><center><img src="../img/lab2/13.png" alt="13" style="zoom:70%;"></center><center style="color:#0" ;="">&#x9009;&#x62E9;&#x6CE2;&#x5F62;&#x683C;&#x5F0F;&#x6587;&#x4EF6;&#x4FDD;&#x5B58;&#x8DEF;&#x5F84;</center> 
&#x52A0;&#x8F7D;&#x65B9;&#x5F0F;&#x4E3A;: &#x70B9;&#x51FB; Wave &#x7A97;&#x53E3;&#x5DE6;&#x4E0A;&#x89D2; File &#x83DC;&#x5355;, &#x9009;&#x62E9; Load -&gt; Macro File.</p></div></div>
<p>&#x5728;&#x8FD0;&#x884C;&#x4EFF;&#x771F;&#x524D;, &#x9996;&#x5148;&#x8981;&#x8BBE;&#x7F6E;&#x4EFF;&#x771F;&#x65F6;&#x95F4;, &#x8FD9;&#x91CC;&#x8BBE;&#x7F6E;&#x4EFF;&#x771F;&#x65F6;&#x95F4;&#x4E3A; 100ns, &#x7136;&#x540E;&#x70B9;&#x51FB;&#x65C1;&#x8FB9;&#x6309;&#x94AE;&#x6B63;&#x5F0F;&#x8FD0;&#x884C;&#x4EFF;&#x771F;.</p>
<center><img src="../img/lab2/14.png" alt="14" style="zoom:70%;"></center><center style="color:#0" ;="">&#x8BBE;&#x7F6E;&#x4EFF;&#x771F;&#x65F6;&#x95F4;&#x5E76;&#x8FD0;&#x884C;&#x4EFF;&#x771F;</center> 

<p>&#x4EFF;&#x771F;&#x8FD0;&#x884C;&#x505C;&#x6B62;&#x540E;, &#x70B9;&#x51FB; Wave &#x7A97;&#x53E3;&#x83DC;&#x5355;&#x680F;&#x4E2D;&#x7684;<img src="../img/lab2/17.png" alt="17" style="zoom:100%;">&#x5C06;&#x6CE2;&#x5F62;&#x7F29;&#x653E;&#x5230;&#x6EE1;&#x5C4F;, &#x7136;&#x540E;&#x901A;&#x8FC7;&#x6EDA;&#x52A8;&#x6761;&#x548C; Ctrl + &#x9F20;&#x6807;&#x6EDA;&#x8F6E;&#x5C06;&#x6CE2;&#x5F62;&#x7F29;&#x653E;&#x5230;&#x5408;&#x9002;&#x6BD4;&#x4F8B;.</p>
<center><img src="../img/lab2/15.png" alt="15" style="zoom:100%;"></center><center style="color:#0" ;="">&#x4EFF;&#x771F;&#x6CE2;&#x5F62;</center> 

<p>&#x4E0B;&#x9762;&#x6839;&#x636E;&#x7A0B;&#x5E8F;&#x529F;&#x80FD;, &#x5206;&#x6790;&#x4EFF;&#x771F;&#x6CE2;&#x5F62;:</p>
<ul>
<li>&#x5BC4;&#x5B58;&#x5668;</li>
</ul>
<p>vis_r1_o &#x5728; 0-4 &#x8303;&#x56F4;&#x5185;&#x5FAA;&#x73AF;&#x8BA1;&#x6570;, &#x4E0E;&#x7A0B;&#x5E8F;&#x529F;&#x80FD;&#x76F8;&#x7B26;.</p>
<p>vis_pc_o &#x5728; 0x25-0x29 &#x4E4B;&#x95F4;&#x5FAA;&#x73AF;, &#x4E3A;&#x4EC0;&#x4E48;? &#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x5C31;&#x9700;&#x8981;&#x8FDB;&#x5165;&#x4E4B;&#x524D;&#x751F;&#x6210;&#x7684; &quot;/Task2/keil/code.txt&quot; &#x6587;&#x4EF6;&#x4E00;&#x63A2;&#x7A76;&#x7ADF;&#x4E86;, &#x5728; &quot;code.txt&quot; &#x7684; .text &#x4E2D;&#x6709;&#x8FD9;&#x6837;&#x4E00;&#x6BB5;:</p>
<pre><code>    start
        0x00000048:    2104        .!      MOVS     r1,#4
        0x0000004a:    2000        .       MOVS     r0,#0
        0x0000004c:    1c40        @.      ADDS     r0,r0,#1
        0x0000004e:    4288        .B      CMP      r0,r1
        0x00000050:    d0fb        ..      BEQ      0x4a ; start + 2
        0x00000052:    d1fb        ..      BNE      0x4c ; start + 4
</code></pre><p>&#x8FD9;&#x8868;&#x660E;, &#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x65F6;, &#x53D6;&#x6307;&#x5730;&#x5740;&#x5728; 0x0000004a-0x00000052 &#x4E4B;&#x95F4;&#x5FAA;&#x73AF;, &#x4E0D;&#x96BE;&#x53D1;&#x73B0;, vis_pc_o &#x6070;&#x597D;&#x662F;&#x53D6;&#x6307;&#x5730;&#x5740;&#x53BB;&#x9664; LSB &#x540E;&#x7684;&#x7ED3;&#x679C;.</p>
<ul>
<li>AHB &#x4FE1;&#x53F7;</li>
</ul>
<p>Cortex-M0 &#x91C7;&#x7528;&#x7684;&#x662F;&#x51AF;&#x8BFA;&#x4F9D;&#x66FC;&#x67B6;&#x6784;, &#x6307;&#x4EE4;&#x548C;&#x6570;&#x636E;&#x90FD;&#x8981;&#x901A;&#x8FC7;&#x540C;&#x4E00;&#x4E2A; AHB &#x63A5;&#x53E3;&#x8BBF;&#x95EE;. &#x800C;&#x672C;&#x5B9E;&#x9A8C;&#x4E2D;&#x672A;&#x6D89;&#x53CA;&#x5BF9;&#x6570;&#x636E;&#x7684;&#x8BFB;&#x5199;, &#x6240;&#x4EE5;&#x8FD9;&#x91CC;&#x7684; AHB &#x63A5;&#x53E3;&#x4EC5;&#x7528;&#x4E8E;&#x6307;&#x4EE4;&#x7684;&#x8BFB;&#x53D6;. &#x53E6;&#x5916;, &#x7531;&#x4E8E; Cortex-M0 &#x5185;&#x90E8;&#x672A;&#x8BBE;&#x6709; Cache &#x6765;&#x7F13;&#x5B58;&#x6307;&#x4EE4;&#x548C;&#x6570;&#x636E;, &#x6240;&#x4EE5;&#x5BF9;&#x4E8E;&#x5FAA;&#x73AF;&#x7A0B;&#x5E8F;&#x800C;&#x8A00;, &#x4E5F;&#x9700;&#x8981;&#x4E0D;&#x65AD;&#x53BB;&#x4E3B;&#x5B58;&#x4E2D;&#x8BFB;&#x53D6;&#x540C;&#x4E00;&#x6BB5;&#x6307;&#x4EE4;. &#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x4F1A;&#x770B;&#x5230; HADDR &#x4E0D;&#x65AD;&#x5728; 0x0000004a-0x00000052 &#x4E4B;&#x95F4;&#x5FAA;&#x73AF;, &#x5BF9;&#x5E94;&#x7684; HTRANS &#x5728;&#x4F20;&#x8F93;&#x65F6;&#x53D8;&#x4E3A; 1, HSIZE &#x5728;&#x4F20;&#x8F93;&#x65F6;&#x53D8;&#x4E3A; 2, &#x8868;&#x793A; 32 &#x4F4D;&#x6570;&#x636E;&#x4F20;&#x8F93;, &#x76F8;&#x5E94;&#x7684;&#x6307;&#x4EE4;&#x6570;&#x636E;&#x5728;&#x4E0B;&#x4E00;&#x62CD;&#x8868;&#x73B0;&#x5728; HRDATA &#x603B;&#x7EBF;&#x4E0A;.</p>
<p>&#x82E5;&#x8981;&#x9000;&#x51FA;&#x4EFF;&#x771F;, &#x70B9;&#x51FB;&#x4E3B;&#x7A97;&#x53E3;&#x83DC;&#x5355;&#x4E2D;&#x7684; Simulate -&gt; End Simulation.</p>
<center><img src="../img/lab2/18.png" alt="18" style="zoom:80%;"></center><center style="color:#0" ;="">&#x9000;&#x51FA;&#x4EFF;&#x771F;</center> 

<!-- -->
<div class="panel panel-success"><div class="panel-heading"><h5 class="panel-title" id="&#x547D;&#x4EE4;&#x884C;&#x64CD;&#x4F5C;---&#x4ECE;&#x5C0F;&#x767D;&#x5230;&#x5DE5;&#x7A0B;&#x5E08;"><i class="fa fa-lightbulb-o"></i> &#x547D;&#x4EE4;&#x884C;&#x64CD;&#x4F5C; - &#x4ECE;&#x5C0F;&#x767D;&#x5230;&#x5DE5;&#x7A0B;&#x5E08;</h5></div><div class="panel-body"><p>&#x5728;&#x5DE5;&#x7A0B;&#x4E2D;, &#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x884C;&#x6216;&#x811A;&#x672C;&#x64CD;&#x4F5C;&#x8F6F;&#x4EF6;&#x53EF;&#x4EE5;&#x4E3A;&#x6211;&#x4EEC;&#x8282;&#x7701;&#x5927;&#x91CF;&#x7684;&#x64CD;&#x4F5C;&#x65F6;&#x95F4;, &#x63D0;&#x5347;&#x6211;&#x4EEC;&#x7684;&#x5DE5;&#x4F5C;&#x6548;&#x7387;. &#x719F;&#x7EC3;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x6280;&#x80FD;&#x662F;&#x4E00;&#x4E2A;&#x4F18;&#x79C0;&#x5DE5;&#x7A0B;&#x5E08;&#x5FC5;&#x5907;&#x7684;&#x4E13;&#x4E1A;&#x7D20;&#x8D28;.</p><p>&#x5982;&#x679C;&#x4F60;&#x538C;&#x5026;&#x4E86;&#x7E41;&#x7410;&#x7684;&#x56FE;&#x5F62;&#x754C;&#x9762;&#x64CD;&#x4F5C;, &#x8BF7;&#x8DDF;&#x6211;&#x4E00;&#x8D77;&#x5B66;&#x4E60;&#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x884C;&#x64CD;&#x4F5C; Modelsim &#x5427;.</p><p>Modelsim &#x91C7;&#x7528; TCL &#x547D;&#x4EE4;, &#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x7A97;&#x53E3; (Transcript) &#x4E2D;&#x6267;&#x884C;&#x5355;&#x6761;&#x547D;&#x4EE4;, &#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; do &#x811A;&#x672C;&#x6765;&#x6267;&#x884C;&#x591A;&#x6761;&#x547D;&#x4EE4;. &#x5BF9;&#x4E8E;&#x672C;&#x4EFF;&#x771F;&#x5B9E;&#x9A8C;, &#x8FD9;&#x91CC;&#x7ED9;&#x51FA;&#x4E86;&#x4E00;&#x79CD;&#x7B49;&#x6548;&#x7684; do &#x811A;&#x672C;&#x7684;&#x7F16;&#x5199;&#x65B9;&#x6CD5;, &#x6709;&#x5174;&#x8DA3;&#x7684;&#x540C;&#x5B66;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x5C1D;&#x8BD5;<font color="red">(&#x6CE8;&#x610F;&#x4F60;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;)</font>:</p><p>&#x7F16;&#x5199; &quot;run.do&quot; &#x811A;&#x672C;&#x6587;&#x4EF6;:</p><pre><code class="lang-tcl">vlib work 
vlog <span class="hljs-string">&quot;./CortexM0_SoC_vlg_tst.v&quot;</span> 
vlog <span class="hljs-string">&quot;./rtl/*&quot;</span>
vsim -voptargs=+acc -c work.CortexM0_SoC_vlg_tst
add wave <span class="hljs-string">&quot;CortexM0_SoC_vlg_tst/i1/u_logic/*&quot;</span>
run <span class="hljs-number">100</span>ns
</code></pre><p>&#x5728; Modelsim Transcript &#x7A97;&#x53E3;&#x4E2D;&#x6267;&#x884C;&#x547D;&#x4EE4;:</p><pre><code class="lang-tcl">do run.do
</code></pre></div></div>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By UESTC Intelligent Chip and System Design Lab. &#x91C7;&#x7528;<a href="https://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; &#x7F72;&#x540D;-&#x975E;&#x5546;&#x4E1A;&#x6027;&#x4F7F;&#x7528;-&#x76F8;&#x540C;&#x65B9;&#x5F0F;&#x5171;&#x4EAB; 3.0 &#x4E2D;&#x56FD;&#x5927;&#x9646; &#x8BB8;&#x53EF;&#x534F;&#x8BAE;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> &#x6B64;&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E; 2022-04-23 10:35:33 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="sec_2.html" class="navigation navigation-prev " aria-label="Previous page: 搭建 Keil 工程">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="sec_4.html" class="navigation navigation-next " aria-label="Next page: 下载比特流到 FPGA">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Modelsim 仿真","level":"1.4.3","depth":2,"next":{"title":"下载比特流到 FPGA","level":"1.4.4","depth":2,"path":"lab2/sec_4.md","ref":"lab2/sec_4.md","articles":[]},"previous":{"title":"搭建 Keil 工程","level":"1.4.2","depth":2,"path":"lab2/sec_2.md","ref":"lab2/sec_2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["intopic-toc","callouts","page-footer-ex","-livereload","theme-comscore","-sharing"],"styles":{"website":"styles/styles.css"},"pluginsConfig":{"callouts":{"important":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation-circle"},"question":{"alert":"info","picto":"fa-question-circle"},"hint":{"alert":"success","picto":"fa-lightbulb-o"},"showTypeInHeader":false,"must":{"alert":"warning","picto":"fa-edit"},"flag":{"alert":"success","picto":"fa-flag"},"info":{"alert":"info","picto":"fa-info-circle"},"note":{"alert":"info","picto":"fa-edit"},"fread":{"alert":"info","picto":"fa-comment"}},"intopic-toc":{"isCollapsed":true,"isScrollspyActive":true,"label":"导航","maxDepth":6,"mode":"nested","selector":".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4","visible":true},"page-footer-ex":{"copyright":"By UESTC Intelligent Chip and System Design Lab. 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](https://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"WQ GitBook","gitbook":"*"},"file":{"path":"lab2/sec_3.md","mtime":"2022-04-23T02:35:33.185Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-16T07:13:54.762Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

